package net.tv90.bfmccore.command;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.util.Objects;

import static net.tv90.bfmccore.helper.FlanHelper.getWeaponType;

public class AttachmentCommand implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (label.equalsIgnoreCase("att")) {
            if (args.length == 0) {
                Player p = (Player) sender;
                String item = p.getItemInHand().getType().name();
                String type = getWeaponType(item);
                if (!Objects.equals(type, "Unclassified") && !Objects.equals(type, "ATW") && !Objects.equals(type, "ME")) {
                    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "cc open Attachment_1 " + sender.getName());
                    return true;
                }
                return true;
            }
            return true;
        }
        return true;
    }
}